package cn.wetcland.urban.admin.controller;

import cn.wetcland.urban.admin.dto.AddressUpdateDTO;
import cn.wetcland.urban.admin.dto.CarUpdateDTO;
import cn.wetcland.urban.admin.service.UtCarService;
import cn.wetcland.urban.common.AjaxResponse;
import cn.wetcland.urban.generator.domain.UtCar;
import cn.wetcland.urban.generator.dto.BaseConditionSearchDTO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/car")
public class CarController {
    
    @Resource
    private UtCarService carService;

    @GetMapping("/carList")
    public AjaxResponse carList(BaseConditionSearchDTO searchDTO) {
        Page<UtCar> addressPage = carService.carList(searchDTO);
        return AjaxResponse.success(addressPage);
    }

    @PutMapping("/carUpdate")
    public AjaxResponse carUpdate(@RequestBody CarUpdateDTO updateDTO) {
        carService.carUpdate(updateDTO);
        return AjaxResponse.success();
    }

    @DeleteMapping("/carDelete/{carId}")
    public AjaxResponse carDelete(@PathVariable Long carId) {
        carService.carDelete(carId);
        return AjaxResponse.success();
    }
    
}
